package cn.sciento.boot.data.change.autoconfigure;

import java.util.List;
import cn.sciento.boot.data.change.selector.AbstractEntityTableSelector;
import cn.sciento.boot.data.change.selector.DefaultEntityTableSelector;
import cn.sciento.boot.data.change.selector.manager.DefaultEntityTableSelectorManager;
import cn.sciento.boot.data.change.selector.manager.EntityTableSelectorManager;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class EntityTableSelectorConfiguration {
  @Bean
  DefaultEntityTableSelector defaultEntityTableSelector() {
    DefaultEntityTableSelector selector = new DefaultEntityTableSelector();
    selector.setOrder(0);
    return selector;
  }
  
  @Bean
  @ConditionalOnMissingBean
  EntityTableSelectorManager entityTableSelectorManager(List<AbstractEntityTableSelector> entityTableSelectors) {
    DefaultEntityTableSelectorManager defaultEntityTableSelectorManager = new DefaultEntityTableSelectorManager();
    defaultEntityTableSelectorManager.setEntityTableSelectors(entityTableSelectors);
    return defaultEntityTableSelectorManager;
  }
}
